package org.oos.dao.impl;

import static com.google.api.client.http.HttpMethod.POST;
import static org.oos.ApiUrlProvider.SiteOffers;
import static org.oos.atom.AtomService.atomService;

import org.oos.atom.AtomRequest;
import org.oos.atom.AtomResponse;
import org.oos.atom.OfferFeed;
import org.oos.atom.AtomService.HttpStatusException;
import org.oos.atom.entries.OfferEntry;
import org.oos.atom.entries.impl.OfferEntryImpl;
import org.oos.atom.impl.OfferFeedImpl;
import org.oos.dao.SiteOfferDao;
import org.oos.dao.exceptions.CreationException;
import org.oos.dao.lists.impl.ReadOnlyDynamicList;
import org.oos.model.Site;

import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.UrlEncodedContent;

public class SiteOfferDaoImpl extends
		ReadOnlyAbstractDao<OfferEntry, OfferFeed<OfferEntry>> implements
		SiteOfferDao {

	private static final long serialVersionUID = 8523221364378518951L;
	private String siteSlug = null;

	public SiteOfferDaoImpl() {
		super(OfferFeedImpl.class, OfferEntryImpl.class);
	}

	@Override
	public void setSite(Site site) {
		this.siteSlug = site.getSlug();
	}

	@Override
	public void serSiteSlug(String slug) {
		this.siteSlug = slug;
	}

	@Override
	protected GenericUrl getFeedUrl() {
		if (siteSlug != null) {
			return SiteOffers.getUrl(siteSlug );
		} else {
			throw new NullPointerException("Need a site slug");
		}
	}

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	protected ReadOnlyDynamicList<OfferEntry, OfferFeed<OfferEntry>> getList(
			OfferFeed feed) {
		return new ReadOnlyDynamicList<OfferEntry, OfferFeed<OfferEntry>>(this,
				feed);
	}

	
	
	

}
